package lzc.demo.spring.eureka.server;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;

/**
 * 程序启动入口
 *
 */
@EnableEurekaServer // 开启 Eureka 服务
@SpringBootApplication // springBoot注解,spring在springBoot基础之上来构建项目
public class App {
	
	
	/**
	 * 注入Jetty容器的管理Bean
	 * @param jettyServerCustomizer
	 * @return
	 */
	@Profile("jetty")
	@Bean
	public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory(
			JettyServerCustomizer jettyServerCustomizer) {
		JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory();
		factory.addServerCustomizers(jettyServerCustomizer);
		return factory;
	}

	// spirng boot的标准入口
	public static void main(String[] args) {
		new SpringApplicationBuilder(App.class).web(true).run(args);
	}

}
